<?php

namespace apiend\modules\system\controllers;

use Yii;
use apiend\components\Controller;
use common\models\book\BookRule;

/**
 * 假期管理
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class RuleController extends Controller {

    /**
     * 菜单列表
     * @inheritdoc
     */
    public function actionIndex() {
        return BookRule::findAvilable()->one();
    }

    /**
     * @inheritdoc
     */
    public function actionUpdate($id) {
        $model = BookRule::findOrFail($id);
        $params = Yii::$app->request->post();
        $model->load($params, '');
        if (!$model->save()) {
            parent::error('设置失败');
        }
        return $model;
    }

}
